' ======================================================================
' 执行所有 case
' ======================================================================
Private Sub test_All_Case()
    ' ==================================================
    ' 初始化
    ' ==================================================
    ' 使用列索引初始化
    test_DataFrame_init_by_index
    ' 使用列名初始化
    test_DataFrame_init_by_names
    ' 指定行数
    test_DataFrame_init_set_row_count
    ' 指定列的类型
    test_DataFrame_init_set_col_type
    ' 使用 IDFSeries 来初始化
    test_DataFrame_init_by_IDFSeries
    ' 使用 sheet 数据来初始化
    ' 该方法需要手动测试，并提前准备包含数据的 sheet
    ' test_DataFramme_init_by_sheet_data

    ' ==================================================
    ' 属性
    ' ==================================================
    ' Size 测试
    test_DataFramme_Property_Size
    ' ColumnCount 测试
    test_DataFramme_Property_ColumnCount
    ' ColumnNames 测试
    test_DataFramme_Property_ColumnNames
    ' ID 测试
    test_DataFramme_Property_ID

    ' ==================================================
    ' 可用方法--行操作
    ' ==================================================
    ' 添加空行 appendEmptyRow
    test_DataFramme_Func_appendEmptyRow
    ' 添加空行并拷贝指定行数据 copyAndAppendRow
    test_DataFramme_Func_copyAndAppendRow
    ' 添加一整行数据
    test_DataFramme_Func_appendRowByColDatas
    ' 测试: 添加一整行数据
    test_DataFramme_Func_appendRowByColDataArray
    ' 删除指定行 delRow
    test_DataFramme_Func_delRow
    ' 删除指定行 delRowByIndexArray
    test_DataFramme_Func_delRowByIndexArray
    ' 删除指定行 deepDelRow
    test_DataFramme_Func_deepDelRow
    ' 删除指定行  deepDelRowByIndexArray
    test_DataFramme_Func_deepDelRowByIndexArray

    ' ==================================================
    ' 可用方法--列操作
    ' ==================================================
    ' 检查是否存在指定的列 hasColumn
    test_DataFramme_Func_hasColumn
    ' 检查是否存在指定的列 deepHasColumn
    test_DataFramme_Func_deepHasColumn
    ' 将列索引转换成列名 colIndexToName
    test_DataFramme_Func_colIndexToName
    ' 将列名转换成列索引 colNameToIndex
    test_DataFramme_Func_colNameToIndex
    ' 获取列对象 getCol
    test_DataFramme_Func_getCol
    ' 删除指定索引的列 delCol
    test_DataFramme_Func_delCol
    ' 删除指定索引的列 (使用数组) delColByIndexArray
    test_DataFramme_Func_delColByIndexArray
    ' 删除指定索引的列 deepDelCol
    test_DataFramme_Func_deepDelCol
    ' 删除指定索引的列 (使用数组) deepDelColByIndexArray
    test_DataFramme_Func_deepDelColByIndexArray
    ' 向所有列的末尾添加一个新的列 addCol
    test_DataFramme_Func_addCol

    ' ==================================================
    ' 可用方法--描述符操作
    ' ==================================================
    ' 获取指定行的描述器 getRowDescriptor
    test_DataFramme_Func_getRowDescriptor
    ' 获取指定行列确定的槽位的描述器 getDataDescriptor
    test_DataFramme_Func_getDataDescriptor

    ' ==================================================
    ' 可用方法--数据操作
    ' ==================================================
    ' 读取数据/设置数据 使用列索引 getDataByColIndex + setDataByColIndex
    test_DataFramme_Property_getDataByColIndex_setDataByColIndex
    ' 读取数据/设置数据 使用列名 getDataByColName + setDataByColName
    test_DataFramme_Func_getDataByColName_setDataByColName
End Sub

' ======================================================================
' 测试 case
' ======================================================================
' ==================================================
' 初始化
' ==================================================
' 使用列索引初始化
Private Sub test_DataFrame_init_by_index()
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 5

    Dim idf As IDataFrame
    Set idf = df

    Dim cNames As Collection
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 5
    Debug.Assert cNames.Item(1) = 0
    Debug.Assert cNames.Item(2) = 1
    Debug.Assert cNames.Item(3) = 2
    Debug.Assert cNames.Item(4) = 3
    Debug.Assert cNames.Item(5) = 4
End Sub

' 使用列名初始化
Private Sub test_DataFrame_init_by_names()
    ' 生成列名数组的方式1： 手动设置数组
    Dim dfColNames(0 To 2) As String
    dfColNames(0) = "c1"
    dfColNames(1) = "c2"
    dfColNames(2) = "c3"

    ' 生成列名数组的方式2： 使用 Array 快速生成数组
    ' Dim dfColNames As Variant
    ' dfColNames = Array("c1", "c2", "c3")

    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colNames:= dfColNames

    Dim idf As IDataFrame
    Set idf = df

    Dim cNames As Collection
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 3
    Debug.Assert cNames.Item(1) = "c1"
    Debug.Assert cNames.Item(2) = "c2"
    Debug.Assert cNames.Item(3) = "c3"

End Sub

' 指定行数
Private Sub test_DataFrame_init_set_row_count()
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 5, initRowSize:=10

    Dim idf As IDataFrame
    Set idf = df
    Debug.Assert idf.size = 0

End Sub

' 指定列的类型
Private Sub test_DataFrame_init_set_col_type()
    Dim dfColTypes(0 To 3) As DF_DataType
    dfColTypes(0) = DF_DataType.DF_INT
    dfColTypes(1) = DF_DataType.DF_DECIMAL
    dfColTypes(2) = DF_DataType.DF_STRING
    dfColTypes(3) = DF_DataType.DF_BOOLEAN

    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 4, dTypes:= dfColTypes

    Dim idf As IDataFrame
    Set idf = df

    Dim col As IDFSeries
    Set col = idf.getCol(0)
    Debug.Assert col.DataType = DF_DataType.DF_INT
    Set col = idf.getCol(1)
    Debug.Assert col.DataType = DF_DataType.DF_DECIMAL
    Set col = idf.getCol(2)
    Debug.Assert col.DataType = DF_DataType.DF_STRING
    Set col = idf.getCol(3)
    Debug.Assert col.DataType = DF_DataType.DF_BOOLEAN
End Sub

' 使用 IDFSeries 来初始化
Private Sub test_DataFrame_init_by_IDFSeries()
    ' 1. 创建列数据
    Dim colArray(0 To 2) As IDFSeries

    Dim series As DFSeriesInner

    ' 创建第一个列
    Set series = New DFSeriesInner
    series.Init size:=3, dType:=DF_DataType.DF_STRING
    series.IDFSeries_appendEmpty 3

    Set colArray(0) = series

    ' 创建第二个列
    Set series = New DFSeriesInner
    series.Init size:=3, dType:=DF_DataType.DF_STRING
    series.IDFSeries_appendEmpty 3

    Set colArray(1) = series

    ' 创建第三个列
    Set series = New DFSeriesInner
    series.Init size:=3, dType:=DF_DataType.DF_STRING
    series.IDFSeries_appendEmpty 3

    Set colArray(2) = series

    ' 2. 创建列名
    Dim dfColNames As Variant
    dfColNames = Array("c1", "c2", "c3")

    ' 3. 初始化 df
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitBySeries colArray, dfColNames

    Dim idf As IDataFrame
    Set idf = df

    Debug.Assert idf.Size = 3
End Sub

' 使用 sheet 数据来初始化
' 该方法需要手动测试，并提前准备包含数据的 sheet
Private Sub test_DataFramme_init_by_sheet_data()
    Dim df As DataFrame
    Set df = New DataFrame

    df.InitBySheet _
        Sheets("Sheet9").Range("B3:D8"), _
        Array(DF_DataType.DF_INT, DF_DataType.DF_STRING, DF_DataType.DF_DATE)

    Dim idf As IDataFrame
    Set idf = df

    Debug.Assert idf.ColumnCount = 3
    Debug.Assert idf.Size = 6
End Sub

' ==================================================
' 属性
' ==================================================
' Size 测试
Private Sub test_DataFramme_Property_Size()
    Dim df As DataFrame
    Set df = New DataFrame

    df.Init colCount:= 3

    Dim idf As IDataFrame
    Set idf = df

    Debug.Assert idf.Size = 0

    idf.appendEmptyRow
    Debug.Assert idf.Size = 1
    idf.appendEmptyRow
    Debug.Assert idf.Size = 2
    idf.appendEmptyRow
    Debug.Assert idf.Size = 3
End Sub

' ColumnCount 测试
Private Sub test_DataFramme_Property_ColumnCount()
    Dim df As DataFrame
    Set df = New DataFrame

    df.Init colCount:= 3

    Dim idf As IDataFrame
    Set idf = df

    Debug.Assert idf.ColumnCount = 3
End Sub

' ColumnNames 测试
Private Sub test_DataFramme_Property_ColumnNames()
    ' 1. 列索引作为列名
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 5

    Dim idf As IDataFrame
    Set idf = df

    Dim cNames As Collection
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 5
    Debug.Assert cNames.Item(1) = 0
    Debug.Assert cNames.Item(2) = 1
    Debug.Assert cNames.Item(3) = 2
    Debug.Assert cNames.Item(4) = 3
    Debug.Assert cNames.Item(5) = 4

    '-----------------------------------
    ' 2. 字符串列名
    ' 生成列名数组的方式1： 手动设置数组
    Dim dfColNames(0 To 2) As String
    dfColNames(0) = "c1"
    dfColNames(1) = "c2"
    dfColNames(2) = "c3"

    ' 生成列名数组的方式2： 使用 Array 快速生成数组
    ' Dim dfColNames As Variant
    ' dfColNames = Array("c1", "c2", "c3")

    Set df = New DataFrame
    df.Init colNames:= dfColNames

    Set idf = df

    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 3
    Debug.Assert cNames.Item(1) = "c1"
    Debug.Assert cNames.Item(2) = "c2"
    Debug.Assert cNames.Item(3) = "c3"
End Sub

' ID 测试
Private Sub test_DataFramme_Property_ID()
    ' 1. 初始化时设置 id
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 5, id:="abc"

    ' 2. 获取 id
    Dim idf As IDataFrame
    Set idf = df
    Debug.Assert idf.ID = "abc"

    ' 3. 重设 id
    idf.ID = "xyz"
    Debug.Assert idf.ID = "xyz"
End Sub

' ==================================================
' 可用方法--行操作
' ==================================================
' 添加空行 appendEmptyRow
Private Sub test_DataFramme_Func_appendEmptyRow()
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 5

    Dim idf As IDataFrame
    Set idf = df

    Debug.Assert idf.Size = 0

    ' 插入一个空行
    idf.appendEmptyRow
    Debug.Assert idf.Size = 1

    ' 插入多个空行
    idf.appendEmptyRow 3
    Debug.Assert idf.Size = 4
End Sub

' 添加空行并拷贝指定行数据 copyAndAppendRow
Private Sub test_DataFramme_Func_copyAndAppendRow()
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 5

    Dim idf As IDataFrame
    Set idf = df

    Debug.Assert idf.Size = 0

    ' 插入一行数据
    idf.appendEmptyRow
    idf.setDataByColIndex 0, 0, "d00"
    idf.setDataByColIndex 0, 1, "d01"
    idf.setDataByColIndex 0, 2, "d02"
    idf.setDataByColIndex 0, 3, "d03"
    idf.setDataByColIndex 0, 4, "d04"

    Debug.Assert idf.Size = 1

    ' 拷贝第一行数据
    idf.copyAndAppendRow 0
    Debug.Assert idf.Size = 2

    Debug.Assert idf.getDataByColIndex(0, 0) = "d00"
    Debug.Assert idf.getDataByColIndex(0, 1) = "d01"
    Debug.Assert idf.getDataByColIndex(0, 2) = "d02"
    Debug.Assert idf.getDataByColIndex(0, 3) = "d03"
    Debug.Assert idf.getDataByColIndex(0, 4) = "d04"
End Sub

' 测试: 添加一整行数据
Private Sub test_DataFramme_Func_appendRowByColDatas()
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 5

    Dim idf As IDataFrame
    Set idf = df

    Debug.Assert idf.Size = 0

    ' 插入空行不会生效
    idf.appendRowByColDatas
    ' 插入一行数据: 数据数量 = 列数
    idf.appendRowByColDatas "d00", "d01", "d02", "d03", "d04"
    ' 插入一行数据: 数据数量 < 列数
    idf.appendRowByColDatas "d10", "d11", "d12"
    ' 插入一行数据: 数据数量 > 列数
    idf.appendRowByColDatas "d20", "d21", "d22", "d23", "d24", "d25"

    ' 检查结果
    Debug.Assert idf.Size = 3

    Debug.Assert idf.getDataByColIndex(0, 0) = "d00"
    Debug.Assert idf.getDataByColIndex(0, 1) = "d01"
    Debug.Assert idf.getDataByColIndex(0, 2) = "d02"
    Debug.Assert idf.getDataByColIndex(0, 3) = "d03"
    Debug.Assert idf.getDataByColIndex(0, 4) = "d04"

    Debug.Assert idf.getDataByColIndex(1, 0) = "d10"
    Debug.Assert idf.getDataByColIndex(1, 1) = "d11"
    Debug.Assert idf.getDataByColIndex(1, 2) = "d12"
    Debug.Assert idf.getDataByColIndex(1, 3) = Empty
    Debug.Assert idf.getDataByColIndex(1, 4) = Empty

    Debug.Assert idf.getDataByColIndex(2, 0) = "d20"
    Debug.Assert idf.getDataByColIndex(2, 1) = "d21"
    Debug.Assert idf.getDataByColIndex(2, 2) = "d22"
    Debug.Assert idf.getDataByColIndex(2, 3) = "d23"
    Debug.Assert idf.getDataByColIndex(2, 4) = "d24"
End Sub

' 测试: 添加一整行数据
Private Sub test_DataFramme_Func_appendRowByColDataArray()
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 5

    Dim idf As IDataFrame
    Set idf = df

    Debug.Assert idf.Size = 0

    ' 插入空行不会生效
    idf.appendRowByColDataArray Array()
    ' 插入一行数据: 数据数量 = 列数
    idf.appendRowByColDataArray Array("d00", "d01", "d02", "d03", "d04")
    ' 插入一行数据: 数据数量 < 列数
    idf.appendRowByColDataArray Array("d10", "d11", "d12")
    ' 插入一行数据: 数据数量 > 列数
    idf.appendRowByColDataArray Array("d20", "d21", "d22", "d23", "d24", "d25")

    ' 检查结果
    Debug.Assert idf.Size = 3

    Debug.Assert idf.getDataByColIndex(0, 0) = "d00"
    Debug.Assert idf.getDataByColIndex(0, 1) = "d01"
    Debug.Assert idf.getDataByColIndex(0, 2) = "d02"
    Debug.Assert idf.getDataByColIndex(0, 3) = "d03"
    Debug.Assert idf.getDataByColIndex(0, 4) = "d04"

    Debug.Assert idf.getDataByColIndex(1, 0) = "d10"
    Debug.Assert idf.getDataByColIndex(1, 1) = "d11"
    Debug.Assert idf.getDataByColIndex(1, 2) = "d12"
    Debug.Assert idf.getDataByColIndex(1, 3) = Empty
    Debug.Assert idf.getDataByColIndex(1, 4) = Empty

    Debug.Assert idf.getDataByColIndex(2, 0) = "d20"
    Debug.Assert idf.getDataByColIndex(2, 1) = "d21"
    Debug.Assert idf.getDataByColIndex(2, 2) = "d22"
    Debug.Assert idf.getDataByColIndex(2, 3) = "d23"
    Debug.Assert idf.getDataByColIndex(2, 4) = "d24"
End Sub

' 删除指定行 delRow
Private Sub test_DataFramme_Func_delRow()
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 5

    Dim idf As IDataFrame
    Set idf = df

    Debug.Assert idf.Size = 0

    ' 插入数据
    idf.appendEmptyRow 5
    Debug.Assert idf.Size = 5

    idf.setDataByColIndex 0, 0, "d0"
    idf.setDataByColIndex 1, 0, "d1"
    idf.setDataByColIndex 2, 0, "d2"
    idf.setDataByColIndex 3, 0, "d3"
    idf.setDataByColIndex 4, 0, "d4"

    ' 1. 删除第二行
    idf.delRow 1
    Debug.Assert idf.Size = 4

    Debug.Assert idf.getDataByColIndex(0, 0) = "d0"
    Debug.Assert idf.getDataByColIndex(1, 0) = "d2"
    Debug.Assert idf.getDataByColIndex(2, 0) = "d3"
    Debug.Assert idf.getDataByColIndex(3, 0) = "d4"

    ' 2. 同时删除多行: 删除第 2 + 3 行
    idf.delRow 1, 2

    Debug.Assert idf.Size = 2

    Debug.Assert idf.getDataByColIndex(0, 0) = "d0"
    Debug.Assert idf.getDataByColIndex(1, 0) = "d4"
End Sub

' 删除指定行  delRowByIndexArray
Private Sub test_DataFramme_Func_delRowByIndexArray()
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 5

    Dim idf As IDataFrame
    Set idf = df

    Debug.Assert idf.Size = 0

    ' 插入数据
    idf.appendEmptyRow 5
    Debug.Assert idf.Size = 5

    idf.setDataByColIndex 0, 0, "d0"
    idf.setDataByColIndex 1, 0, "d1"
    idf.setDataByColIndex 2, 0, "d2"
    idf.setDataByColIndex 3, 0, "d3"
    idf.setDataByColIndex 4, 0, "d4"

    ' 1. 删除第二行
    idf.delRowByIndexArray Array(1)
    Debug.Assert idf.Size = 4

    Debug.Assert idf.getDataByColIndex(0, 0) = "d0"
    Debug.Assert idf.getDataByColIndex(1, 0) = "d2"
    Debug.Assert idf.getDataByColIndex(2, 0) = "d3"
    Debug.Assert idf.getDataByColIndex(3, 0) = "d4"

    ' 2. 使用数组删除
    Dim delIdxes(0 To 1) As Integer
    delIdxes(0) = 1
    delIdxes(1) = 2
    idf.delRowByIndexArray delIdxes

    Debug.Assert idf.Size = 2

    Debug.Assert idf.getDataByColIndex(0, 0) = "d0"
    Debug.Assert idf.getDataByColIndex(1, 0) = "d4"
End Sub

' 删除指定行 deepDelRow
Private Sub test_DataFramme_Func_deepDelRow()
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 5

    Dim idf As IDataFrame
    Set idf = df

    Debug.Assert idf.Size = 0

    ' 插入数据
    idf.appendEmptyRow 5
    Debug.Assert idf.Size = 5

    idf.setDataByColIndex 0, 0, "d0"
    idf.setDataByColIndex 1, 0, "d1"
    idf.setDataByColIndex 2, 0, "d2"
    idf.setDataByColIndex 3, 0, "d3"
    idf.setDataByColIndex 4, 0, "d4"

    ' 1. 删除第二行
    idf.deepDelRow 1
    Debug.Assert idf.Size = 4

    Debug.Assert idf.getDataByColIndex(0, 0) = "d0"
    Debug.Assert idf.getDataByColIndex(1, 0) = "d2"
    Debug.Assert idf.getDataByColIndex(2, 0) = "d3"
    Debug.Assert idf.getDataByColIndex(3, 0) = "d4"

    ' 2. 同时删除多行: 删除第 2 + 3 行
    idf.deepDelRow 1, 2

    Debug.Assert idf.Size = 2

    Debug.Assert idf.getDataByColIndex(0, 0) = "d0"
    Debug.Assert idf.getDataByColIndex(1, 0) = "d4"
End Sub

' 删除指定行 deepDelRowByIndexArray
Private Sub test_DataFramme_Func_deepDelRowByIndexArray()
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 5

    Dim idf As IDataFrame
    Set idf = df

    Debug.Assert idf.Size = 0

    ' 插入数据
    idf.appendEmptyRow 5
    Debug.Assert idf.Size = 5

    idf.setDataByColIndex 0, 0, "d0"
    idf.setDataByColIndex 1, 0, "d1"
    idf.setDataByColIndex 2, 0, "d2"
    idf.setDataByColIndex 3, 0, "d3"
    idf.setDataByColIndex 4, 0, "d4"

    ' 1. 删除第二行
    idf.deepDelRowByIndexArray Array(1)
    Debug.Assert idf.Size = 4

    Debug.Assert idf.getDataByColIndex(0, 0) = "d0"
    Debug.Assert idf.getDataByColIndex(1, 0) = "d2"
    Debug.Assert idf.getDataByColIndex(2, 0) = "d3"
    Debug.Assert idf.getDataByColIndex(3, 0) = "d4"

    ' 2. 使用数组删除
    Dim delIdxes(0 To 1) As Integer
    delIdxes(0) = 1
    delIdxes(1) = 2
    idf.deepDelRowByIndexArray delIdxes

    Debug.Assert idf.Size = 2

    Debug.Assert idf.getDataByColIndex(0, 0) = "d0"
    Debug.Assert idf.getDataByColIndex(1, 0) = "d4"
End Sub

' ==================================================
' 可用方法--列操作
' ==================================================
' 检查是否存在指定的列 hasColumn
Private Sub test_DataFramme_Func_hasColumn()
    ' 1. 列索引作为列名
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 3

    Dim idf As IDataFrame
    Set idf = df

    Debug.Assert idf.hasColumn(0) = True
    Debug.Assert idf.hasColumn(1) = True
    Debug.Assert idf.hasColumn(2) = True
    Debug.Assert idf.hasColumn(3) = False
    Debug.Assert idf.hasColumn(4) = False

    '-----------------------------------
    ' 2. 字符串列名
    ' 生成列名数组的方式1： 手动设置数组
    Dim dfColNames(0 To 2) As String
    dfColNames(0) = "c1"
    dfColNames(1) = "c2"
    dfColNames(2) = "c3"

    ' 生成列名数组的方式2： 使用 Array 快速生成数组
    ' Dim dfColNames As Variant
    ' dfColNames = Array("c1", "c2", "c3")

    Set df = New DataFrame
    df.Init colNames:= dfColNames

    Set idf = df

    ' 检查列名
    Debug.Assert idf.hasColumn("c1") = True
    Debug.Assert idf.hasColumn("c2") = True
    Debug.Assert idf.hasColumn("c3") = True
    Debug.Assert idf.hasColumn("c4") = False
    ' 检查列索引
    Debug.Assert idf.hasColumn(0) = True
    Debug.Assert idf.hasColumn(1) = True
    Debug.Assert idf.hasColumn(2) = True
    Debug.Assert idf.hasColumn(3) = False
End Sub

' 检查是否存在指定的列 deepHasColumn
Private Sub test_DataFramme_Func_deepHasColumn()
    ' 1. 列索引作为列名
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 3

    Dim idf As IDataFrame
    Set idf = df

    Debug.Assert idf.deepHasColumn(0) = True
    Debug.Assert idf.deepHasColumn(1) = True
    Debug.Assert idf.deepHasColumn(2) = True
    Debug.Assert idf.deepHasColumn(3) = False
    Debug.Assert idf.deepHasColumn(4) = False

    '-----------------------------------
    ' 2. 字符串列名
    ' 生成列名数组的方式1： 手动设置数组
    Dim dfColNames(0 To 2) As String
    dfColNames(0) = "c1"
    dfColNames(1) = "c2"
    dfColNames(2) = "c3"

    ' 生成列名数组的方式2： 使用 Array 快速生成数组
    ' Dim dfColNames As Variant
    ' dfColNames = Array("c1", "c2", "c3")

    Set df = New DataFrame
    df.Init colNames:= dfColNames

    Set idf = df

    ' 检查列名
    Debug.Assert idf.deepHasColumn("c1") = True
    Debug.Assert idf.deepHasColumn("c2") = True
    Debug.Assert idf.deepHasColumn("c3") = True
    Debug.Assert idf.deepHasColumn("c4") = False
    ' 检查列索引
    Debug.Assert idf.deepHasColumn(0) = True
    Debug.Assert idf.deepHasColumn(1) = True
    Debug.Assert idf.deepHasColumn(2) = True
    Debug.Assert idf.deepHasColumn(3) = False
End Sub

' 将列索引转换成列名 colIndexToName
Private Sub test_DataFramme_Func_colIndexToName()
    ' 1. 列索引作为列名
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 3

    Dim idf As IDataFrame
    Set idf = df

    Debug.Assert idf.colIndexToName(0) = "0"
    Debug.Assert idf.colIndexToName(1) = "1"
    Debug.Assert idf.colIndexToName(2) = "2"

    '-----------------------------------
    ' 2. 字符串列名
    ' 生成列名数组的方式1： 手动设置数组
    Dim dfColNames(0 To 2) As String
    dfColNames(0) = "c1"
    dfColNames(1) = "c2"
    dfColNames(2) = "c3"

    Set df = New DataFrame
    df.Init colNames:= dfColNames

    Set idf = df

    Debug.Assert idf.colIndexToName(0) = "c1"
    Debug.Assert idf.colIndexToName(1) = "c2"
    Debug.Assert idf.colIndexToName(2) = "c3"
End Sub

' 将列名转换成列索引 colNameToIndex
Private Sub test_DataFramme_Func_colNameToIndex()
    ' 1. 列索引作为列名
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 3

    Dim idf As IDataFrame
    Set idf = df

    Debug.Assert idf.colNameToIndex("0") = 0
    Debug.Assert idf.colNameToIndex("1") = 1
    Debug.Assert idf.colNameToIndex("2") = 2

    '-----------------------------------
    ' 2. 字符串列名
    ' 生成列名数组的方式1： 手动设置数组
    Dim dfColNames(0 To 2) As String
    dfColNames(0) = "c1"
    dfColNames(1) = "c2"
    dfColNames(2) = "c3"

    Set df = New DataFrame
    df.Init colNames:= dfColNames

    Set idf = df

    Debug.Assert idf.colNameToIndex("c1") = 0
    Debug.Assert idf.colNameToIndex("c2") = 1
    Debug.Assert idf.colNameToIndex("c3") = 2
End Sub

' 获取列对象 getCol
Private Sub test_DataFramme_Func_getCol()
    ' 1. 列索引作为列名
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 3

    Dim idf As IDataFrame
    Set idf = df

    ' 插入数据
    idf.appendEmptyRow 1

    idf.setDataByColIndex 0, 0, "d00"
    idf.setDataByColIndex 0, 1, "d01"
    idf.setDataByColIndex 0, 2, "d02"

    ' 获取第一列
    Dim col As IDFSeries
    Set col = idf.getCol(0)
    Debug.Assert col.Size = 1
    Debug.Assert col.getData(0) = "d00"

    Set col = idf.getCol(1)
    Debug.Assert col.Size = 1
    Debug.Assert col.getData(0) = "d01"

    Set col = idf.getCol(2)
    Debug.Assert col.Size = 1
    Debug.Assert col.getData(0) = "d02"

    '-----------------------------------
    ' 2. 字符串列名
    ' 生成列名数组的方式1： 手动设置数组
    Dim dfColNames(0 To 2) As String
    dfColNames(0) = "c1"
    dfColNames(1) = "c2"
    dfColNames(2) = "c3"

    Set df = New DataFrame
    df.Init colNames:= dfColNames

    Set idf = df

    ' 插入数据
    idf.appendEmptyRow 1

    idf.setDataByColIndex 0, 0, "d00"
    idf.setDataByColIndex 0, 1, "d01"
    idf.setDataByColIndex 0, 2, "d02"

    ' 获取第一列
    Set col = idf.getCol("c1")
    Debug.Assert col.Size = 1
    Debug.Assert col.getData(0) = "d00"

    Set col = idf.getCol("c2")
    Debug.Assert col.Size = 1
    Debug.Assert col.getData(0) = "d01"

    Set col = idf.getCol("c3")
    Debug.Assert col.Size = 1
    Debug.Assert col.getData(0) = "d02"
End Sub

' 删除指定索引的列 delCol
Private Sub test_DataFramme_Func_delCol()
    ' 1. 列索引作为列名
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 3

    Dim idf As IDataFrame
    Set idf = df

    idf.delCol 0

    Debug.Assert idf.ColumnCount = 2
    Dim cNames As Collection
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 2
    Debug.Assert cNames.Item(1) = 1
    Debug.Assert cNames.Item(2) = 2
    '-----------------------------------
    ' 2. 字符串列名
    ' 生成列名数组的方式1： 手动设置数组
    Dim dfColNames(0 To 2) As String
    dfColNames(0) = "c1"
    dfColNames(1) = "c2"
    dfColNames(2) = "c3"

    Set df = New DataFrame
    df.Init colNames:= dfColNames

    Set idf = df

    idf.delCol 0

    Debug.Assert idf.ColumnCount = 2
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 2
    Debug.Assert cNames.Item(1) = "c2"
    Debug.Assert cNames.Item(2) = "c3"
End Sub

' 删除指定索引的列 (使用数组) delColByIndexArray
Private Sub test_DataFramme_Func_delColByIndexArray()
    ' 1. 列索引作为列名
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 4

    Dim idf As IDataFrame
    Set idf = df

    ' 删除一个索引
    idf.delColByIndexArray Array(0)

    Debug.Assert idf.ColumnCount = 3

    Dim cNames As Collection
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 3
    Debug.Assert cNames.Item(1) = 1
    Debug.Assert cNames.Item(2) = 2
    Debug.Assert cNames.Item(3) = 3

    ' 删除两个索引
    idf.delColByIndexArray Array(1, 2)

    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 1
    Debug.Assert cNames.Item(1) = 1
    '-----------------------------------
    ' 2. 字符串列名 --- 使用列索引删除
    ' 生成列名数组的方式1： 手动设置数组
    Dim dfColNames(0 To 3) As String
    dfColNames(0) = "c1"
    dfColNames(1) = "c2"
    dfColNames(2) = "c3"
    dfColNames(3) = "c4"

    Set df = New DataFrame
    df.Init colNames:= dfColNames

    Set idf = df

    ' 删除一个索引
    idf.delColByIndexArray Array(0)

    Debug.Assert idf.ColumnCount = 3
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 3
    Debug.Assert cNames.Item(1) = "c2"
    Debug.Assert cNames.Item(2) = "c3"
    Debug.Assert cNames.Item(3) = "c4"

    ' 删除两个索引
    idf.delColByIndexArray Array(1, 2)

    Debug.Assert idf.ColumnCount = 1
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 1
    Debug.Assert cNames.Item(1) = "c2"

    '-----------------------------------
    ' 3. 字符串列名 --- 使用列名删除
    ' 生成列名数组的方式1： 手动设置数组
    dfColNames(0) = "c1"
    dfColNames(1) = "c2"
    dfColNames(2) = "c3"
    dfColNames(3) = "c4"

    Set df = New DataFrame
    df.Init colNames:= dfColNames

    Set idf = df

    ' 删除一个索引
    idf.delColByIndexArray Array("c1")

    Debug.Assert idf.ColumnCount = 3
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 3
    Debug.Assert cNames.Item(1) = "c2"
    Debug.Assert cNames.Item(2) = "c3"
    Debug.Assert cNames.Item(3) = "c4"

    ' 删除两个索引
    idf.delColByIndexArray Array("c3", "c4")

    Debug.Assert idf.ColumnCount = 1
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 1
    Debug.Assert cNames.Item(1) = "c2"
End Sub

' 删除指定索引的列 deepDelCol
Private Sub test_DataFramme_Func_deepDelCol()
    ' 1. 列索引作为列名
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 3

    Dim idf As IDataFrame
    Set idf = df

    idf.deepDelCol 0

    Debug.Assert idf.ColumnCount = 2
    Dim cNames As Collection
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 2
    Debug.Assert cNames.Item(1) = 1
    Debug.Assert cNames.Item(2) = 2
    '-----------------------------------
    ' 2. 字符串列名
    ' 生成列名数组的方式1： 手动设置数组
    Dim dfColNames(0 To 2) As String
    dfColNames(0) = "c1"
    dfColNames(1) = "c2"
    dfColNames(2) = "c3"

    Set df = New DataFrame
    df.Init colNames:= dfColNames

    Set idf = df

    idf.deepDelCol 0

    Debug.Assert idf.ColumnCount = 2
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 2
    Debug.Assert cNames.Item(1) = "c2"
    Debug.Assert cNames.Item(2) = "c3"
End Sub

' 删除指定索引的列 (使用数组) deepDelColByIndexArray
Private Sub test_DataFramme_Func_deepDelColByIndexArray()
    ' 1. 列索引作为列名
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 4

    Dim idf As IDataFrame
    Set idf = df

    ' 删除一个索引
    idf.deepDelColByIndexArray Array(0)

    Debug.Assert idf.ColumnCount = 3

    Dim cNames As Collection
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 3
    Debug.Assert cNames.Item(1) = 1
    Debug.Assert cNames.Item(2) = 2
    Debug.Assert cNames.Item(3) = 3

    ' 删除两个索引
    idf.deepDelColByIndexArray Array(1, 2)

    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 1
    Debug.Assert cNames.Item(1) = 1
    '-----------------------------------
    ' 2. 字符串列名 --- 使用列索引删除
    ' 生成列名数组的方式1： 手动设置数组
    Dim dfColNames(0 To 3) As String
    dfColNames(0) = "c1"
    dfColNames(1) = "c2"
    dfColNames(2) = "c3"
    dfColNames(3) = "c4"

    Set df = New DataFrame
    df.Init colNames:= dfColNames

    Set idf = df

    ' 删除一个索引
    idf.deepDelColByIndexArray Array(0)

    Debug.Assert idf.ColumnCount = 3
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 3
    Debug.Assert cNames.Item(1) = "c2"
    Debug.Assert cNames.Item(2) = "c3"
    Debug.Assert cNames.Item(3) = "c4"

    ' 删除两个索引
    idf.deepDelColByIndexArray Array(1, 2)

    Debug.Assert idf.ColumnCount = 1
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 1
    Debug.Assert cNames.Item(1) = "c2"

    '-----------------------------------
    ' 3. 字符串列名 --- 使用列名删除
    ' 生成列名数组的方式1： 手动设置数组
    dfColNames(0) = "c1"
    dfColNames(1) = "c2"
    dfColNames(2) = "c3"
    dfColNames(3) = "c4"

    Set df = New DataFrame
    df.Init colNames:= dfColNames

    Set idf = df

    ' 删除一个索引
    idf.deepDelColByIndexArray Array("c1")

    Debug.Assert idf.ColumnCount = 3
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 3
    Debug.Assert cNames.Item(1) = "c2"
    Debug.Assert cNames.Item(2) = "c3"
    Debug.Assert cNames.Item(3) = "c4"

    ' 删除两个索引
    idf.deepDelColByIndexArray Array("c3", "c4")

    Debug.Assert idf.ColumnCount = 1
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 1
    Debug.Assert cNames.Item(1) = "c2"
End Sub

' 向所有列的末尾添加一个新的列 addCol
Private Sub test_DataFramme_Func_addCol()
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 3

    Dim idf As IDataFrame
    Set idf = df

    Debug.Assert idf.ColumnCount = 3

    ' 添加一个列
    idf.addCol "cx", DF_DataType.DF_DATE
    Debug.Assert idf.ColumnCount = 4

    Dim cNames As Collection
    Set cNames = idf.ColumnNames
    Debug.Assert cNames.Count = 4
    Debug.Assert cNames.Item(1) = 0
    Debug.Assert cNames.Item(2) = 1
    Debug.Assert cNames.Item(3) = 2
    Debug.Assert cNames.Item(4) = "cx"

    Dim col As IDFSeries
    Set col = idf.getCol(3)
    Debug.Assert col.DataType = DF_DataType.DF_DATE
End Sub

' ==================================================
' 可用方法--描述符操作
' ==================================================
' 获取指定行的描述器 getRowDescriptor
Private Sub test_DataFramme_Func_getRowDescriptor()
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 3

    Dim idf As IDataFrame
    Set idf = df

    idf.appendEmptyRow

    ' 1. 第一次获取行描述器，并且不创建，将会返回 nothing
    Dim rowDescriptor As IDFDescriptor
    Set rowDescriptor = idf.getRowDescriptor(0, needCreate:= False)

    Debug.Assert rowDescriptor Is Nothing

    ' 2. 第一次获取行描述器，并创建描述器
    Set rowDescriptor = idf.getRowDescriptor(0, needCreate:= True)

    Debug.Assert Not rowDescriptor Is Nothing

    ' 3. 第二次获取行描述器，和第一次获取的一样
    Dim rowDescriptor2 As IDFDescriptor
    Set rowDescriptor2 = idf.getRowDescriptor(0, needCreate:= True)

    Debug.Assert rowDescriptor Is rowDescriptor2
End Sub

' 获取指定行列确定的槽位的描述器 getDataDescriptor
Private Sub test_DataFramme_Func_getDataDescriptor()
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 3

    Dim idf As IDataFrame
    Set idf = df

    idf.appendEmptyRow

    ' 1. 第一次获取数据描述器，并且不创建，将会返回 nothing
    Dim descriptor As IDFDescriptor
    Set descriptor = idf.getDataDescriptor(0, 0, needCreate:= False)

    Debug.Assert descriptor Is Nothing

    ' 2. 第一次获取行描述器，并创建描述器
    Set descriptor = idf.getDataDescriptor(0, 0, needCreate:= True)

    Debug.Assert Not descriptor Is Nothing

    ' 3. 第二次获取行描述器，和第一次获取的一样
    Dim descriptor2 As IDFDescriptor
    Set descriptor2 = idf.getDataDescriptor(0, 0, needCreate:= True)

    Debug.Assert descriptor Is descriptor2
End Sub

' ==================================================
' 可用方法--数据操作
' ==================================================
' 读取数据/设置数据 使用索引 getDataByColIndex + setDataByColIndex
Private Sub test_DataFramme_Property_getDataByColIndex_setDataByColIndex()
    Dim df As DataFrame
    Set df = New DataFrame
    df.Init colCount:= 3

    Dim idf As IDataFrame
    Set idf = df

    ' 添加一行，并设置第一行第一列的数据
    idf.appendEmptyRow
    idf.setDataByColIndex 0, 0, "abc"

    ' 获取第一行第一列已经设置的数据
    Debug.Assert idf.getDataByColIndex(0, 0) = "abc"
    ' 没有设置数据的位置上获取的结果是 empty
    Debug.Assert IsEmpty(idf.getDataByColIndex(0, 1))
End Sub

' 读取数据/设置数据 使用列名 getDataByColName + setDataByColName
Private Sub test_DataFramme_Func_getDataByColName_setDataByColName()
    Dim dfColNames(0 To 2) As String
    dfColNames(0) = "c1"
    dfColNames(1) = "c2"
    dfColNames(2) = "c3"

    Set df = New DataFrame
    df.Init colNames:= dfColNames

    Dim idf As IDataFrame
    Set idf = df

    ' 添加一行，并设置第一行第一列的数据
    idf.appendEmptyRow
    idf.setDataByColName 0, "c1", "abc"

    ' 获取第一行第一列已经设置的数据
    Debug.Assert idf.getDataByColName(0, "c1") = "abc"
    ' 没有设置数据的位置上获取的结果是 empty
    Debug.Assert IsEmpty(idf.getDataByColName(0, "c2"))
End Sub
